package com.groupseven.happycampus.common.instener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.groupseven.happycampus.common.bo.CarBo;
import com.groupseven.happycampus.common.pojo.Car;
import com.groupseven.happycampus.service.CarService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;





///**
// * @BeLongsProject: wangrihui
// * @BeLongsPackage: com.wrh.common.instener
// * @Author: WRH
// * @CreateTime: 2022-07-22 15:21
// * @Description: TODO
// * @Version: 1.0
// */
@Component
@Scope("prototype")     // 注意 这里要设置成多例模式
public class WebCarListener extends AnalysisEventListener<CarBo> {

    @Autowired
    private CarService carService;


    @Override
    public void invoke(CarBo bo, AnalysisContext analysisContext) {
        System.out.println(bo);
        Car car = new Car();
        BeanUtils.copyProperties(bo, car);
        carService.addCar(car);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}